Strict

Import mojo
Import agfx



Class TPolyline Extends TPrimitive
	
	Field type:Int = -1
	
	
	Method New()
		Super.New(PRIMITIVE_TYPE_POLYLINE)
	End Method
	
	
	Method ToString:String()
		Local res:String = ""
		For Local p:TVector2 = EachIn Self.points
			res = res + "|"+ p.ToString()
		Next
		Return res
	End Method
	
	Method Draw:Void()
		Local p1:TVector2
		Local p2:TVector2
				
		For Local i:Int = 0 To Self.points.Size()-2
			p1 = Self.points.Get(i)
			p2 = Self.points.Get(i+1)
			DrawLine(p1.x,p1.y,p2.x,p2.y)			
		Next
		
	End Method
	
	Method Update:Void(recalc_center:Bool=True,recalc_bbox:Bool=True,recalc_edge:Bool=True)
		
		If recalc_edge Then Self.CalcEdges()
		If recalc_center Then Self.CalcCenter()
		If recalc_bbox Then Self.CalcBoundingBox()
		
	End Method
End Class